//
//  UIButton+FinishClickButton.m
//  FlowerRainGround
//
//  Created by lanou on 16/4/20.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "UIButton+FinishClickButton.h"

//用runtime要导入系统的框架
#import <objc/runtime.h>
static const char *UIButtonClick;//相当于唯一的标识符
@implementation UIButton (FinishClickButton)

//重写set  get方法
- (void)setBlock:(FinishClickButtonBlock)block
{
    //第二个是指针的地址
    objc_setAssociatedObject(self, &UIButtonClick, block, OBJC_ASSOCIATION_COPY_NONATOMIC);
    [self addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    
    
    
    
}

- (FinishClickButtonBlock)block
{
    return objc_getAssociatedObject(self, &UIButtonClick);
}

- (void)click
{
    if (self.block) {
        self.block();//无参
    }
    
}


@end
